home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / swish.11 / src / swish.h < prev   
C/C++ Source or Header  |  1995-03-13  |  11KB  |  286 lines

  1. /*
  2. ** Copyright (C) 1995, Enterprise Integration Technologies Corp.        
  3. ** All Rights Reserved.
  4. ** Kevin Hughes, kevinh@eit.com 
  5. ** 3/11/94
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <math.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #ifdef NEXTSTEP
  14. #include <sys/dir.h>
  15. #else
  16. #include <dirent.h>
  17. #endif
  18. #include <ctype.h>
  19. #include <stdlib.h>
  20. #include <time.h>
  21. #include <setjmp.h>
  22.  
  23. #define VERSION "1.1.1"
  24. #define INDEXFILE "index.swish"
  25. #define INDEXHEADER "# SWISH format 1.1"
  26.  
  27. #define MAXFILELEN 1000
  28. #define MAXSTRLEN 1000
  29. #define MAXWORDLEN 1000
  30. #define MAXTITLELEN 200
  31. #define MAXSUFFIXLEN 10
  32. #define MAXENTLEN 10
  33. #define HASHSIZE 101
  34. #define BIGHASHSIZE 1009
  35.  
  36. #define TI_OPEN 1
  37. #define TI_CLOSE 2
  38. #define TI_FOUND 4
  39. #define NOWORD "thisisnotaword"
  40. #define SECSPERMIN 60
  41.  
  42. #define NO_RULE 0
  43. #define AND_RULE 1
  44. #define OR_RULE 2
  45. #define NOT_RULE 3
  46.  
  47. #define IN_FILE 1
  48. #define IN_TITLE 2
  49. #define IN_HEAD 4
  50. #define IN_BODY 8
  51. #define IN_COMMENTS 16
  52. #define IN_HEADER 32
  53. #define IN_EMPHASIZED 64
  54. #define IN_ALL 127
  55.  
  56. #define MAXLONGLEN 16
  57. #define MAXCHARS 68
  58. #define MAXHEADCHARS MAXLONGLEN * MAXCHARS
  59. #define STOPWORDPOS MAXCHARS - 3
  60. #define FILELISTPOS MAXCHARS - 2
  61. #define FILEOFFSETPOS MAXCHARS - 1
  62.  
  63. #include "config.h"
  64.  
  65. struct sortresult {
  66.         char *fileinfo;
  67.         int rank;
  68.         struct sortresult *left;
  69.         struct sortresult *right;
  70. };
  71.  
  72. struct result {
  73.         int filenum;
  74.         int rank;
  75.     int structure;
  76.         struct result *next;
  77. };
  78.  
  79. struct file {
  80.         char *filename;
  81.         char *title;
  82.         int size;
  83.         struct file *next;
  84. };
  85.  
  86. struct filenum {
  87.     int fileshort;
  88.     long filelong;
  89.     struct filenum *next;
  90. };
  91.  
  92. struct location {
  93.         int filenum;
  94.         int frequency;
  95.         int emphasized;
  96.     int structure;
  97.         struct location *next;
  98. };
  99.  
  100. struct entry {
  101.         char *word;
  102.         int tfrequency;
  103.         struct location *locationlist;
  104.         struct entry *left;
  105.         struct entry *right;
  106. };
  107.  
  108. struct sortentry {
  109.         char *filename;
  110.         char *title;
  111.         struct sortentry *left;
  112.         struct sortentry *right;
  113. };
  114.  
  115. struct swline {
  116.         char *line;
  117.         struct swline *next;
  118. };
  119.  
  120. struct fwordtotal {
  121.         int filenum;
  122.         int totalwords;
  123.         struct fwordtotal *next;
  124. };
  125.  
  126. #ifndef MAIN_FILE
  127. #define VAR extern
  128. #else
  129. #define VAR
  130. #endif
  131.  
  132. VAR struct file *filelist;
  133. VAR struct entry *entrylist;
  134.  
  135. VAR struct swline *pathconlist;
  136. VAR struct swline *dirconlist;
  137. VAR struct swline *fileconlist;
  138. VAR struct swline *titconlist;
  139. VAR struct swline *fileislist;
  140. VAR struct swline *suffixlist;
  141. VAR struct swline *nocontentslist;
  142. VAR struct swline *replacelist;
  143. VAR struct swline *searchwordlist;
  144. VAR struct swline *dirlist;
  145. VAR struct swline *indexlist;
  146. VAR struct swline *hashstoplist[HASHSIZE];
  147.  
  148. VAR struct result *resulthashlist[HASHSIZE];
  149. VAR struct fwordtotal *fwordtotals[BIGHASHSIZE];
  150. VAR struct filenum *filehashlist[BIGHASHSIZE];
  151.  
  152. VAR long offsets[MAXCHARS];
  153. VAR int verbose;
  154. VAR int bigrank;
  155. VAR int maxhits;
  156. VAR int totalwords;
  157. VAR int followsymlinks;
  158. VAR int commonerror;
  159.  
  160. VAR char indexn[MAXSTRLEN];
  161. VAR char indexd[MAXSTRLEN];
  162. VAR char indexp[MAXSTRLEN];
  163. VAR char indexa[MAXSTRLEN];
  164. VAR char errorstr[MAXSTRLEN];
  165.  
  166. #ifdef MAIN_FILE
  167.  
  168. char *indexchars = "abcdefghijklmnopqrstuvwxyz&#;0123456789_\\|/-+=?!@$%^'\"`~,.<>[]{}";
  169.  
  170. char *defaultstopwords[] = {
  171. "a", "about", "above", "according", "across", "actually", "adj", "after", 
  172. "afterwards", "again", "against", "all", "almost", "alone", "along", 
  173. "already", "also", "although", "always", "among", "amongst", "an", "and", 
  174. "another", "any", "anyhow", "anyone", "anything", "anywhere", "are", "aren", 
  175. "aren't", "around", "as", "at", "be", "became", "because", "become", "becomes", 
  176. "becoming", "been", "before", "beforehand", "begin", "beginning", "behind", 
  177. "being", "below", "beside", "besides", "between", "beyond", "billion", "both", 
  178. "but", "by", "can", "can't", "cannot", "caption", "co", "could", "couldn",
  179. "couldn't", "did", "didn", "didn't", "do", "does", "doesn", "doesn't", "don",
  180. "don't", "down", "during", "each", "eg", "eight", "eighty", "either", "else",
  181. "elsewhere", "end", "ending", "enough", "etc", "even", "ever", "every",
  182. "everyone", "everything", "everywhere", "except", "few", "fifty", "first",
  183. "five", "for", "former", "formerly", "forty", "found", "four", "from",
  184. "further", "had", "has", "hasn", "hasn't", "have", "haven", "haven't",
  185. "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", 
  186. "hers", "herself", "him", "himself", "his", "how", "however", "hundred", 
  187. "ie", "i.e.", "if", "in", "inc", "inc.", "indeed", "instead", "into", "is",
  188. "isn", "isn't", "it", "its", "itself", "last", "later", "latter", "latterly",
  189. "least", "less", "let", "like", "likely", "ll", "ltd", "made", "make",
  190. "makes", "many", "maybe", "me", "meantime", "meanwhile", "might", "million",
  191. "miss", "more", "moreover", "most", "mostly", "mr", "mrs", "much", "must",
  192. "my", "myself", "namely", "neither", "never", "nevertheless", "next", "nine",
  193. "ninety", "no", "nobody", "none", "nonetheless", "noone", "nor", "not",
  194. "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one",
  195. "only", "onto", "or", "other", "others", "otherwise", "our", "ours",
  196. "ourselves", "out", "over", "overall", "own", "per", "perhaps", "rather",
  197. "re", "recent", "recently", "same", "seem", "seemed", "seeming", "seems",
  198. "seven", "seventy", "several", "she", "should", "shouldn", "shouldn't",
  199. "since", "six", "sixty", "so", "some", "somehow", "someone", "something",
  200. "sometime", "sometimes", "somewhere", "still", "stop", "such", "taking",
  201. "ten", "than", "that", "the", "their", "them", "themselves", "then",
  202. "thence", "there", "thereafter", "thereby", "therefore", "therein",
  203. "thereupon", "these", "they", "thirty", "this", "those", "though",
  204. "thousand", "three", "through", "throughout", "thru", "thus", "to",
  205. "together", "too", "toward", "towards", "trillion", "twenty", "two", "under",
  206. "unless", "unlike", "unlikely", "until", "up", "upon", "us", "used", "using",
  207. "ve", "very", "via", "was", "wasn", "we", "we", "well", "were", "weren",
  208. "weren't", "what", "whatever", "when", "whence", "whenever", "where", 
  209. "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", 
  210. "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", 
  211. "whomever", "whose", "why", "will", "with", "within", "without", "won", 
  212. "would", "wouldn", "wouldn't", "yes", "yet", "you", "your", "yours",
  213. "yourself", "yourselves", NULL };
  214.  
  215. char *entities[] = {
  216. "", " ", " ", "", "!", "!", """, """, "\"", "", "#", "#",
  217. "", "$", "$", "", "%", "%", "&", "&", "&", "", "'", "'",
  218. "", "+", "+", "", ",", ",", "", "-", "-", "", ".", ".",
  219. "", "/", "/", "", "0", "0", "", "1", "1", "", "2", "2",
  220. "", "3", "3", "", "4", "4", "", "5", "5", "", "6", "6",
  221. "", "7", "7", "", "8", "8", "", "9", "9", "", ":", "",
  222. "", ";", ";", "<", "<", "<", "", "=", "=", ">", ">", ">",
  223. "", "?", "?", "", "@", "@", "", "A", "A", "", "B", "B",
  224. "", "C", "C", "", "D", "D", "", "E", "E", "", "F", "F",
  225. "", "G", "G", "", "H", "H", "", "I", "I", "", "J", "J",
  226. "", "K", "K", "", "L", "L", "", "M", "M", "", "N", "N",
  227. "", "O", "O", "", "P", "P", "", "Q", "Q", "", "R", "R",
  228. "", "S", "S", "", "T", "T", "", "U", "U", "", "V", "V",
  229. "", "W", "W", "", "X", "X", "", "Y", "Y", "", "Z", "Z",
  230. "", "[", "[", "", "\", "\\", "", "]", "]", "", "^", "^",
  231. "", "_", "-", "", "`", "`", "", "a", "a", "", "b", "b",
  232. "", "c", "c", "", "d", "d", "", "e", "e", "", "f", "f",
  233. "", "g", "g", "", "h", "h", "", "i", "i", "", "j", "j",
  234. "", "k", "k", "", "l", "l", "", "m", "m", "", "n", "n",
  235. "", "o", "o", "", "p", "p", "", "q", "q", "", "r", "r",
  236. "", "s", "s", "", "t", "t", "", "u", "u", "", "v", "v",
  237. "", "w", "w", "", "x", "x", "", "y", "y", "", "z", "z",
  238. "", "{", "{", "", "|", "|", "", "}", "}", "", "~", "~",
  239. " ", " ", " ", "¡", "¡", "", "¢", "¢", "",
  240. "£", "£", "", "¤", "¤", "", "¥", "¥", "",
  241. "¦", "¦", "", "§", "§", "", "&die", "¨", "",
  242. "©", "©", "", "ª", "ª", "", "«", "«", "",
  243. "¬", "¬", "", "­", "­", "", "®", "®", "",
  244. "¯on", "¯", "", "°ree", "°", "", "±", "±", "",
  245. "²", "²", "", "³", "³", "", "´", "´", "",
  246. "µ", "µ", "", "&mu", "¶", "", "·", "·", "",
  247. "&Cedilla", "¸", "", "¹", "¹", "", "º", "º", "",
  248. "»", "»", "", "¼", "¼", "", "½", "½", "",
  249. "¾", "¾", "", "¿", "¿", "", "À", "À", "A",
  250. "Á", "Á", "A", "Â", "Â", "A", "Ã", "Ã", "A",
  251. "Ä", "Ä", "A", "Å", "Å", "A", "Æ", "Æ", "A",
  252. "Ç", "Ç", "C", "È", "È", "E", "É", "É", "E",
  253. "Ê", "Ê", "E", "Ë", "Ë", "E", "Ì", "Ì", "E",
  254. "Í", "Í", "I", "Î", "Î", "I", "Ï", "Ï", "I",
  255. "Ð", "Ð", "", "Ñ", "Ñ", "N", "Ò", "Ò", "O",
  256. "Ó", "Ó", "O", "Ô", "Ô", "O", "Õ", "Õ", "O",
  257. "Ö", "Ö", "O", "×", "×", "", "Ø", "Ø", "O",
  258. "Ù", "Ù", "U", "Ú", "Ú", "U", "Û", "Û", "U",
  259. "Ü", "Ü", "U", "Ý", "Ý", "Y", "Þ", "Þ", "",
  260. "ß", "ß", "", "à", "à", "a", "á", "á", "a",
  261. "â", "â", "a", "ã", "ã", "a", "ä", "ä", "a",
  262. "å", "å", "a", "æ", "æ", "a", "ç", "ç", "c",
  263. "è", "è", "e", "é", "é", "e", "ê", "ê", "e",
  264. "ë", "ë", "e", "ì", "ì", "i", "í", "í", "i",
  265. "î", "î", "i", "ï", "ï", "i", "ð", "ð", "",
  266. "ñ", "ñ", "n", "ò", "ò", "o", "ó", "ó", "o",
  267. "ô", "ô", "o", "õ", "õ", "o", "ö", "ö", "o",
  268. "÷", "÷", "", "ø", "ø", "o", "ù", "ù", "u",
  269. "ú", "ú", "u", "û", "û", "u", "ü", "ü", "u",
  270. "ý", "ý", "y", "þ", "þ", "", "ÿ", "ÿ", "y",
  271. NULL };
  272.  
  273. #else
  274. extern char *indexchars;
  275. extern char *defaultstopwords[];
  276. extern char *entities[];
  277. #endif
  278.  
  279. #ifdef MAIN_FILE
  280. int main();
  281. void usage();
  282. void printversion();
  283. void printrunning();
  284. long getthetime();
  285. #endif
  286.